package acm.天梯赛4;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

public class D {
    public static void main(String[] args) throws ParseException {
        Scanner sc=new Scanner(System.in);
        int count = sc.nextInt();
        Calendar calendar=Calendar.getInstance();
        calendar.set(2013,2,24);
        while (count-- > 0) {
            int n = sc.nextInt();
            Calendar c1= (Calendar) calendar.clone();
            c1.add(Calendar.DATE,n);
            System.out.print(new SimpleDateFormat("yyyy/MM/dd").format(c1.getTime())+" ");
            c1.add(Calendar.DATE,-(n*2));
            System.out.println(new SimpleDateFormat("yyyy/MM/dd").format(c1.getTime()));
        }
    }
}
